package com.fvff.sanctuary.model;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import java.io.Serializable;

/**
 * Phone
 */
@Entity(name = "PHONE")
public final class Phone implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "PHONE_ID")
    private Long id;

    @OneToOne(mappedBy = "person")
    private Person person;

    @Override
    public boolean equals(final Object o) {
        return o != null && (o == this || o.getClass() == getClass() && EqualsBuilder.reflectionEquals(this, o));
    }

    @Override
    public int hashCode() {
        return HashCodeBuilder.reflectionHashCode(this);
    }
}
